package leetcode.剑指offer.剑指II;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2021/9/25 15:14
 * @description：
 */
public class 剑指_II_006_排序数组中两个数字之和 {
    @Test
    public void test() {
        Solution solution = new Solution();
    }

    class Solution {
        public int[] twoSum(int[] numbers, int target) {
            int l = 0;
            int r = numbers.length - 1;
            while (l < r) {
                int cur = numbers[l] + numbers[r];
                if (cur > target) r--;
                else if (cur < target) l++;
                else return new int[]{l, r};
            }
            return null;
        }
    }
}
